#include "color_console.h"

ColorConsole* ColorConsole::COLOR_CONSOLE_INSTANCE = new ColorConsole();

ColorConsole* ColorConsole::getInstance()
{
	return COLOR_CONSOLE_INSTANCE;
}

void ColorConsole::setColor(WORD color)
{
	HANDLE outHandle = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(outHandle, color);
}

void ColorConsole::resetColorToDefault()
{
	HANDLE outHandle = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(outHandle, FB_DEFAULT);
}

void ColorConsole::print(WORD color, std::string content)
{
	setColor(color);
	std::cout << content;
	resetColorToDefault();
}

void ColorConsole::printOk()
{
	print(F_YELLOW, "[");
	print(F_GREEN | F_LIGHT, "OK");
	print(F_YELLOW, "]");
}

void ColorConsole::printNo()
{
	print(F_YELLOW, "[");
	print(F_RED | F_LIGHT, "NO");
	print(F_YELLOW, "]");
}
